#!/bin/bash

NUM_VEZES=$1

NANTS="0.5 1.0"
LS_VAR="0 1"

#Create the test dir
TEST_DIR="testes"
mkdir -p $TEST_DIR

#Reset the test dir
rm -rf $TEST_DIR/*

for BASE in `ls bases`; do

	BASE_DIR="bases/${BASE}/it0 bases/${BASE}/it1 bases/${BASE}/it2 bases/${BASE}/it3 bases/${BASE}/it4" 
	#for base in BASE_DIR e tirar a media...

	TEST_FILE_BASE="${TEST_DIR}/${BASE}.txt"
	TEST_FILE_NOVA_BASE="${TEST_DIR}/${BASE}-nova.txt"
		
	for ant in $NANTS; do

	    for l in $LS_VAR; do

	        for ((i=0; i<$NUM_VEZES; i++)); do

	            RUN_ACO="./run-aco.sh ${BASE_DIR} $ant $l"
	            CORRECT_CLASSIFIED=`$RUN_ACO 2> /dev/null`

	            SELC_FEAT=`echo $CORRECT_CLASSIFIED | cut -d' ' -f2`
	            TOTAL_FEAT=`echo $CORRECT_CLASSIFIED | cut -d' ' -f3`
	            CORREC_CLASS_BASE=`echo $CORRECT_CLASSIFIED | cut -d' ' -f4`
	            CORREC_CLASS_NOVA_BASE=`echo $CORRECT_CLASSIFIED | cut -d' ' -f5`

				NUM_FORM=`echo "$ant * ($SELC_FEAT + 1)" | bc -l`
				
				echo "Teste número $((i + 1))" 
				echo "Numero de formigas: $NUM_FORM"
				echo "Busca local: $l"

	            echo $CORRECT_CLASSIFIED

	            echo "$NUM_FORM $l $TOTAL_FEAT $CORREC_CLASS_BASE" >> $TEST_FILE_BASE
	            echo "$NUM_FORM $l $SELC_FEAT $CORREC_CLASS_NOVA_BASE" >> $TEST_FILE_NOVA_BASE
	
				echo ""
	        done
	     done
	done
done
